<?php

namespace App\Models;

use Illuminate\Support\Facades\Storage;

class CourseTypeModel extends BaseModel
{

    protected $table = 'cm_type';


    // 关联科目
    public function subject()
    {
        return $this->belongsTo(SubjectModel::class, 's_id', 'id');
    }

    // 关联课程
    public function question()
    {
        return $this->hasMany(QuestionModel::class, 't_id', 'id');
    }

    public function getImgUrlAttribute($value)
    {
        return $value ? Storage::disk('public')->url($value) : '';
    }
}
